//
//  ZXTabbar.m
//  ZXOCWeiBo
//
//  Created by mac on 15/12/1.
//  Copyright © 2015年 itcast. All rights reserved.
//

#import "ZXTabbar.h"

@interface ZXTabbar ()

@property(nonatomic,strong)UIButton* plusBtn;

@end


@implementation ZXTabbar
//通过xib的时候调用
//-(instancetype)initWithCoder:(NSCoder *)aDecoder
//{
//    
//}


-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        //添加加号符号
        [self setupPlusBtn];
    }
    return self;
}

-(void)setupPlusBtn
{
    UIButton * plusBtn  = [[UIButton alloc]init];
    [plusBtn setBackgroundImage:[UIImage imageNamed:@"tabbar_compose_button"] forState:UIControlStateNormal];
    [plusBtn setBackgroundImage:[UIImage imageNamed:@"tabbar_compose_button_highlighted"] forState:UIControlStateHighlighted];
    [plusBtn setImage:[UIImage imageNamed:@"tabbar_compose_icon_add"] forState:UIControlStateNormal];
    [plusBtn setImage:[UIImage imageNamed:@"tabbar_compose_icon_add_highlighted"] forState:UIControlStateHighlighted];
    [self addSubview:plusBtn];
    
    plusBtn.size = CGSizeMake(64, 44);
    
    self.plusBtn = plusBtn;
}

-(void)layoutSubviews
{
    [super layoutSubviews];

    CGFloat centerX = self.w * 0.5;
    CGFloat centerY = self.h * 0.5;
    
    //设置按钮的中心位置
    self.plusBtn.center = CGPointMake(centerX, centerY);
    
       //重新布局
    //遍历子控件判断是否是UITabBarButton
    for (UIView * view in self.subviews)
    {
        if ([view isKindOfClass:NSClassFromString(@"UITabBarButton")])
        {
//            NSLog(@"%@",[view class]);
        }
    }
    
 
   
}
                

@end
